import Vue from 'vue'
import VueRouter from 'vue-router'
import No from '../views/no.vue'


Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/home.vue'),
    children:[
      {
        path: '/guanzhu',
        name: 'guanzhu',
        component: () => import('../views/home/guanzhu.vue')
      },
      {
        path: '/home/tuijian',
        name: 'tuijian',
        component: () => import('../views/home/tuijian.vue')
      },
      {
        path: '/home/bikeng',
        name: 'bikeng',
        component: () => import('../views/home/bikeng.vue')
      },
      {
        path: '/home/anli/',
        name: 'anli',
        component: () => import('../views/home/anli.vue')
      },
      {
        path: '/home/anli2',
        name: 'anli2',
        component: () => import('../views/home/anli2.vue')
      },
      {
        path: '/home/params:news',
        name: 'params',
        component: () => import('../views/home/params.vue')
      },
      {
        path: '/home/luyoushouwei',
        name: 'luyoushouwei',
        component: () => import('../views/home/luyoushouwei.vue')
      },
      {
        path:"/",
        // 重新定位方向
        redirect:"/guanzhu"
      },
    ]
  },
  {
    path: '/decorate',
    name: 'decorate',
    component: () => import('../views/decorate.vue'),
    children:[
      {
        path: '/decor/all',
        name: 'all',
        component: () => import('../views/decor/all.vue')
      },
      {
        path:"/",
        // 重新定位方向
        redirect:"/decor/all"
      },
    ]
  },
  {
    path: '/near',
    name: 'near',
    component: () => import('../views/near.vue')
  },
  {
    path: '/collection',
    name: 'collection',
    component: () => import('../views/collection.vue'),
    children:[
      {
        path: '/collec/shoucang',
        name: 'shoucang',
        component: () => import('../views/collec/shoucang.vue')
      },
      {
        path: '/collec/like',
        name: 'like',
        component: () => import('../views/collec/like.vue')
      },
      {
        path:"/",
        // 重新定位方向
        redirect:"/collec/shoucang"
      },
    ]
  },
  {
    path: '/my',
    name: 'my',
    component: () => import('../views/my.vue')
  },
  {
    path: '/myym',
    name: 'myym',
    component: () => import('../views/myym.vue')
  },
  {
    path: '/myzc',
    name: 'myzc',
    component: () => import('../views/myzc.vue')
  },
  {
    path: '/xiangqing',
    name: 'xiangqing',
    component: () => import('../views/home/xiangqing.vue')
  },
  {
    path:"/",
    // 重新定位方向
    redirect:"/home"
  },
  {
    path: '*',
    name: 'no',
    component: No
  }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to,from,next)=>{
  console.log("to",to)
  console.log("from",from)


  if(to.path=="/home/luyoushouwei"){
    alert("您没有登录请您登录后在试！！！")
    next("/guanzhu")
  }else{
    next()
  }
 
})

export default router
